home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig04_05.jar / Ch04 / Fig04_05 / Fig04_05.cpp
C/C++ Source or Header  |  1997-10-13  |  497b  |  23 lines

  1. // Fig. 4.5: fig04_05.cpp
  2. // Initialize array s to the even integers from 2 to 20.
  3. #include <iostream.h>
  4. #include <iomanip.h>
  5.  
  6. int main()
  7. {
  8.    const int arraySize = 10;
  9.    int j, s[ arraySize ];
  10.  
  11.    for ( j = 0; j < arraySize; j++ )   // set the values
  12.       s[ j ] = 2 + 2 * j;
  13.  
  14.    cout << "Element" << setw( 13 ) << "Value" << endl;
  15.  
  16.    for ( j = 0; j < arraySize; j++ )   // print the values
  17.       cout << setw( 7 ) << j << setw( 13 ) << s[ j ] << endl;
  18.  
  19.    return 0;
  20. }
  21.  
  22.  
  23.